#coding:utf-8
#author:zhouchuang

import requests
from bs4 import BeautifulSoup

url = "https://www.gscq.me/search-战狼-0.htm"
headers = {
    'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36',
    'Cookie':'bbs_sid=vld3ktalpmav70t8im5ubk32cd; UM_distinctid=165d2f0aef72a1-0d2b83171077ba-1130685c-1fa400-165d2f0aef862; CNZZDATA1273003273=1605308940-1536840771-https%253A%252F%252Fwww.jianshu.com%252F%7C1536840771'
}

def getFirst(url):
    wb_date = requests.get(url,headers=headers)
    Soup = BeautifulSoup(wb_date.text,'lxml')
    secret = []
    names = Soup.select('#body > div > div > div.col-lg-10.mx-auto > div > div > ul > li > div > div.message.mt-1.break-all > h6 > a')
    lianjies = Soup.select('#body > div > div > div.col-lg-10.mx-auto > div > div > ul > li > div > div.message.mt-1.break-all > h6 > a')
    for name,lianjie in zip(names,lianjies):
        data = {
            '名称':name.get_text(),
            '链接':lianjie.get('href')
        }
        # print(data)
        zhizhang = lianjie.get('href')
        secret.append(zhizhang)
    print(secret)
    return secret


# def getNext(b):
#     for i in b:
#         wb_data = requests.get(i)
#         soup = BeautifulSoup(wb_data.text,'lxml')
#         somethings = soup.select('#body > div > div > div.col-lg-9.main > div.card.card-thread > div > div.message.break-all > fieldset > ul > li > a')
#         print(somethings)
# result = getFirst(url)
# # getFirst(url)
# getNext(result)

# 测试
def getNext(b):
    wb_data = requests.get(b)
    soup = BeautifulSoup(wb_data.text,'lxml')
    somethings = soup.select('#body > div > div > div.col-lg-9.main > div.card.card-thread > div > div.message.break-all > fieldset > ul > li > a')

    print(somethings)
urlsome = 'https://www.gscq.me/'+'thread-6279.htm'
getNext(urlsome)
